const { execSync } = require('child_process');
const UploadOss = require('./src/upload-oss.js');
const path = require('path');
debugger
let count = 0;
const emoji = {
  ing: '---o((⊙﹏⊙))o---',
  success: '😁',
  fail: '😭',
}
new UploadOss({
  uploadFrom: path.resolve(__dirname, ''),
  uploadTo: 'test111',
  limit: 100,
  success() {
    console.log(`${emoji.success}========upload JS调用(绝对路径) test success ${emoji.success}`);
   
  },
  fail() {
    console.log(`${emoji.fail}========upload JS调用(绝对路径) test success ${emoji.fail}`);
    process.reallyExit(1);
  }
}).upload('./src');

console.log(`--------uploadFile命令行 testing ${emoji.ing}`);
execSync('upload-oss uploadFile --file=./README.md --uploadTo=test111');
console.log(`${emoji.success}========uploadFile命令行 test success ${emoji.success}`);
updateTestStatus();

console.log(`--------upload命令行 testing ${emoji.ing}`);
execSync('upload-oss upload --uploadFrom=src --uploadTo=test111');
console.log(`${emoji.success}========upload命令行 test success ${emoji.success}`);
updateTestStatus();


console.log(`--------uploadFile JS调用(相对路径) testing ${emoji.ing}`);
new UploadOss({
  uploadTo: 'tal-miniprogram',
  limit: 100,
  success() {
    console.log(`${emoji.success}========uploadFile JS调用(相对路径) test success ${emoji.success}`);
    updateTestStatus();
  },
  fail() {
    console.log(`${emoji.fail}========uploadFile JS调用(相对路径) test success ${emoji.fail}`);
    process.reallyExit(1);
  }
}).uploadFile('./README.md');

console.log(`--------uploadFile JS调用(绝对路径) testing ${emoji.ing}`);
new UploadOss({
  uploadTo: 'tal-miniprogram',
  limit: 100,
  success() {
    console.log(`${emoji.success}========uploadFile JS调用(绝对路径) test success ${emoji.success}`);
    updateTestStatus();
  },
  fail() {
    console.log(`${emoji.fail}========uploadFile JS调用(绝对路径) test success ${emoji.fail}`);
    process.reallyExit(1);
  }
}).uploadFile(path.resolve(__dirname, './README.md'));



console.log(`--------upload JS调用(相对路径) testing ${emoji.ing}`);
new UploadOss({
  uploadFrom: 'src/sdk',
  uploadTo: 'tal-miniprogram',
  limit: 100,
  success() {
    console.log(`${emoji.success}========upload JS调用(相对路径) test success ${emoji.success}`);
    updateTestStatus();
  },
  fail() {
    console.log(`${emoji.fail}========upload JS调用(相对路径) test success ${emoji.fail}`);
    process.reallyExit(1);
  }
}).upload();

console.log(`--------upload JS调用(绝对路径) testing ${emoji.ing}`);
new UploadOss({
  uploadFrom: path.resolve(__dirname, 'src/sdk'),
  uploadTo: 'tal-miniprogram',
  limit: 100,
  success() {
    console.log(`${emoji.success}========upload JS调用(绝对路径) test success ${emoji.success}`);
    updateTestStatus();
  },
  fail() {
    console.log(`${emoji.fail}========upload JS调用(绝对路径) test success ${emoji.fail}`);
    process.reallyExit(1);
  }
}).upload();

function updateTestStatus() {
  count++;
  if (count === 6) {
    console.log(` ${emoji.success}${emoji.success}${emoji.success} ---------all test success--------- ${emoji.success}${emoji.success}${emoji.success}`);
  }
}